#include <string>
#include <iostream>
#include <sstream>

#include "baseEffect.h"
#include "boardEffect.h"
#include "basePlayer.h"
#include "baseCard.h"
#include "baseBoard.h"
#include "moveInfo.h"

using namespace std;

class baseEffect;

boardEffect::boardEffect(string aName, string aDescription, bool aAllowRow, bool aAllowCol) : baseEffect(aName, aDescription), allowRow(aAllowRow), allowCol(aAllowCol) {}

string boardEffect::toString()
{
    stringstream out;

    out << baseEffect::toString() << endl;
    out << "applies on board" << endl;

    return out.str();
}

bool boardEffect::isRowAllowed()
{
    return allowRow;
}

bool boardEffect::isColAllowed()
{
    return allowCol;
}

baseEffect::effectType boardEffect::getType()
{
    return type;
}

void boardEffect::doEffect(void* aMoveInfo)
{
    moveInfo* mvInfo = (moveInfo*)aMoveInfo;

    if(mvInfo)
    {
        switch(mvInfo->getMv())
        {
            case boardEffect::right:
                getHostCard()->getBoard()->moveRightRow(mvInfo->getRowOrColNum());
                break;
            case boardEffect::left:
                getHostCard()->getBoard()->moveLeftRow(mvInfo->getRowOrColNum());
                break;
            case boardEffect::up:
                getHostCard()->getBoard()->moveUpColumn(mvInfo->getRowOrColNum());
                break;
            case boardEffect::down:
                getHostCard()->getBoard()->moveDownColumn(mvInfo->getRowOrColNum());
                break;
            default:
                break;
        }

        getHostCard()->getOwner()->actionDone();
    }
}
